<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% content_for :page_title do %>
  <% if !@files_domain && !@unauthorized_user  %>
    {{#t}}Please Log In{{/t}}
  <% else %>
    {{#t}}Unauthorized{{/t}}
  <% end %>

<% end %>
<% @show_left_side = false %>
<% @show_embedded_chat = false %>
<div id="unauthorized_holder">
  <% css_bundle("unauthorized_message") %>
  <div id="unauthorized_message">
    <h2 class="ui-state-error">
      <% if @needs_cookies -%>
        {{#t}}Cookies Required{{/t}}
      <% elsif !@files_domain && @unauthorized_user %>
        {{#t}}Please Log In{{/t}}
      <% elsif @unauthorized_reason == :unpublished %>
        {{#t}}Not Yet Available{{/t}}
      <% else -%>
        {{#t}}Unauthorized{{/t}}
      <% end -%>
    </h2>
    <% if @unauthorized_user && @current_user != @unauthorized_user %>
      <p><%= mt 'unauthorized_user_is_other', "%{current_user}, you are not authorized to view this page.  The link you followed to get here was for **%{unauthorized_user} (%{unauthorized_user_email})**.  If that's you, you may want to log out and log back in with that email address to gain access to this page.", :current_user => @current_user.name, :unauthorized_user => @unauthorized_user.name, :unauthorized_user_email => @unauthorized_user.email %>
      </p>
    <% elsif @unauthorized_user %>
      <p>
        <%= t "%{user_name}, you'll need to *log in* before you can view that page.", user_name: @unauthorized_user.name, wrapper: link_to(login_url, '\1') %>
      </p>
    <% elsif @unauthorized_message %>
      <p><%= @unauthorized_message %></p>
    <% elsif @needs_cookies %>
      <p>{{#t}}Cookies are not enabled on your browser. Please adjust this in your security preferences before continuing.{{/t}}</p>
    <% elsif @files_domain %>
      <p>{{#t}}Access to this page is limited to authorized users.  You do not currently have permission to view this page.{{/t}}</p>
    <% elsif @context %>
      <p>
        <% if @context.try_rescue(:is_public) %>
          <%= mt 'public_course', 'This page is part of the content for the course, **%{course}**.', :course => @context.name %>
        <% end %>
      {{#t}}It appears that you don't have permission to access this page.  Please make sure you're authorized to view this content.{{/t}}
      <% if Setting.get("show_feedback_link", "false") == "true" %>
        {{#t}}If you think you should be able to view this page, please use the "Help" link to notify support of the problem.{{/t}}
      <% end %>
      </p>
    <% end %>
  </div>
</div>
